import 'package:flutter/material.dart';
import 'package:flutter_boost/flutter_boost.dart';

class YQScreenUtil {
  static late double _screenWidth;
  static late double _screenHeight;
  static late double _statusBarHeight;
  static late double _bottomSafeHeight;
  static late double _pixelRatio;

  static void init(BuildContext context) {
    final mediaQuery = MediaQuery.of(context);
    final size = mediaQuery.size;
    final padding = mediaQuery.padding;
    final devicePixelRatio = mediaQuery.devicePixelRatio;

    _screenWidth = size.width;
    _screenHeight = size.height;
    _statusBarHeight = padding.top;
    _bottomSafeHeight = padding.bottom;
    _pixelRatio = devicePixelRatio;
  }

  /// 获取状态栏高度
  static double getStatusBarHeight() {
    return _statusBarHeight;
  }

  /// 获取底部安全区域高度
  static double getBottomSafeHeight() {
    return _bottomSafeHeight;
  }

  /// 获取屏幕宽度
  static double getScreenWidth() {
    return _screenWidth;
  }

  /// 获取屏幕高度
  static double getScreenHeight() {
    return _screenHeight;
  }

  /// 获取设备像素比
  static double getPixelRatio() {
    return _pixelRatio;
  }

  /// 获取实际状态栏高度（考虑像素比）
  static double getActualStatusBarHeight() {
    return _statusBarHeight / _pixelRatio;
  }

  /// 获取实际底部安全区域高度（考虑像素比）
  static double getActualBottomSafeHeight() {
    return _bottomSafeHeight / _pixelRatio;
  }
}
